local skill = fk.CreateSkill {
  name = "#ling__diyu_tu_skill",
  attached_equip = "ling__diyu_tu",
  tags = { Skill.Compulsory },
}

skill:addEffect(fk.EnterDying, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skill.name) or data.who ~= player then return false end
    local current = player.room.logic:getCurrentEvent():findParent(GameEvent.Dying, true)
    if current then
      local first = player.room.logic:getEventsOfScope(GameEvent.Dying, 1, function(e)
        return e.data.who == player
      end, Player.HistoryTurn)[1]
      return first and first.id == current.id
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(3, skill.name)
  end,
})

return skill
